<?php
if(!defined('RSMSINC'))
{
	exit("Request Error!");
}
function lib_artlistreco(&$ctag,&$refObj)
{
	global $dsql,$envs;
	
	//属性处理
	$attlist="row|10,titlelen|24,flag|,notflag|";
	FillAttsDefault($ctag->CAttribute->Items,$attlist);
	extract($ctag->CAttribute->Items, EXTR_SKIP);
	$revalue = '';
	$wheres = "Where recommend=1 ";
	if (!empty($flag))
	{
		$wheres .= "And flag='$flag' ";
	} else if (!empty($notflag)) 
	{
		$wheres .= "And flag<>'$notflag' ";
	}
	
	$innerText = trim($ctag->GetInnerText());
	if(empty($innerText)) $innerText = GetSysTemplets('memberlist.htm');
	
	$ctp = new RsmsTagParse();
	$ctp->SetNameSpace('field','[',']');
	$ctp->LoadSource($innerText);

	//你需编写的代码，不能用echo之类语法，把最终返回值传给$revalue
	//------------------------------------------------------
	$sql = "Select * from #@__archives $wheres order by senddate desc limit 0,$row";
	$dsql->SetQuery($sql);
	$dsql->Execute();
	while($row = $dsql->GetArray()) {
		$row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
				$row['arcrank'],$row['filename']);
		if($row['source'] == '本站')
		{
			$crow = $dsql->GetOne ("Select typename from #@__arctype Where id=$row[typeid]");
			$row['source'] = $crow['typename'];
		}
		$row['title'] = u8_title_substr ($row['title'], $titlelen);
		/*$wlen = str_zh($row['title']);
		if ($wlen[2] > $titlelen)
		{
			$row['title'] = cn_substr($row['title'],$titlelen);
			$row['title'] = $row['title']."...";
		}*/
		foreach($ctp->CTags as $tagid=>$ctag){
			if(isset($row[$ctag->GetName()]))
			{ $ctp->Assign($tagid,$row[$ctag->GetName()]); }
		}
		$revalue .= $ctp->GetResult();
	}
	
	//------------------------------------------------------
	return $revalue;
}
?>